package com.foton.logistic.util;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.Service;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Rect;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Handler;
import android.provider.Settings;
import android.support.v4.content.FileProvider;
import android.support.v4.widget.SwipeRefreshLayout;
import android.telephony.TelephonyManager;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.EditText;
import android.widget.Toast;

import com.foton.logistic.R;
import com.foton.logistic.base.BaseApplication;
import com.foton.logistic.listener.IOnDialogListener;
import com.foton.logistic.model.order.OrderEntity;
import com.foton.logistic.model.order.StatusEntity;
import com.foton.logistic.util.tool.StringUtil;
import com.foton.logistic.view.dialog.DialogUtil;

import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;


public class OptionUtil {
    public static String tag = "OptionUtil";


    //订单状态 撤销
    public static final int ORDER_STATUS = -1;
    //订单状态 手动标记异常
    public static final int ORDER_STATUS_0 = 0;
    //订单状态 待调度
    public static final int ORDER_STATUS_1 = 1;
    //订单状态 接单
    public static final int ORDER_STATUS_10 = 10;
    //订单状态 待发车
    public static final int ORDER_STATUS_2 = 2;
    //订单状态 出发签到
    public static final int ORDER_STATUS_20 = 20;
    //订单状态 出发拍照-已装车
    public static final int ORDER_STATUS_21 = 21;
    //订单状态 已发车
    public static final int ORDER_STATUS_3 = 3;
    //订单状态 到达签到
    public static final int ORDER_STATUS_30 = 30;
    //订单状态 已到达
    public static final int ORDER_STATUS_4 = 4;
    //订单状态 到达拍照-已完成
    public static final int ORDER_STATUS_40 = 40;
    //订单状态 到达未拍照
    public static final int ORDER_STATUS_41 = 41;
    //订单状态 应到达
    public static final int ORDER_STATUS_5 = 5;
    //订单状态 未识别
    public static final int ORDER_STATUS_6 = 6;
    //订单状态 已延期
    public static final int ORDER_STATUS_7 = 7;


    /**
     * 拨打电话
     *
     * @param context
     */
    public static void call(final Context context, final String tel) {
        try {
            Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + tel));
            context.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 开启全屏设置
     *
     * @param activity
     */
    public static void startFullScreen(Activity activity) {
        activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);//全屏
    }

    /**
     * 取消全屏设置
     *
     * @param activity
     */
    public static void quitFullScreen(Activity activity) {
        final WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
        attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
        activity.getWindow().setAttributes(attrs);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    }


    /**
     * 隐藏键盘
     *
     * @param activity
     */
    public static void closeKeyBoard(Activity activity) {

        try {
            activity.getWindow().setSoftInputMode(
                    WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
            ((InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE))
                    .hideSoftInputFromWindow(activity.getCurrentFocus()
                                    .getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 打开键盘
     *
     * @param activity
     */
    public static void openKeyBoard(Handler handler, final Activity activity, int delay) {
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                try {
                    InputMethodManager imm = (InputMethodManager) activity.getSystemService
                            (Service.INPUT_METHOD_SERVICE);
                    imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }
        }, delay);
    }


    /**
     * 获取状态栏高度
     *
     * @param activity
     * @return
     */
    public static int getStatusBarHeight(Activity activity) {
        Rect frame = new Rect();
        activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
        int statusBarHeight = frame.top;
        return statusBarHeight;
    }

    /**
     * 获取标题栏高度
     *
     * @param activity
     * @return
     */
    public static int getTitleBarHeight(Activity activity) {
        Rect frame = new Rect();
        activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
        int statusBarHeight = frame.top;
        int contentTop = activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();
        //statusBarHeight是上面所求的状态栏的高度
        int titleBarHeight = contentTop - statusBarHeight;
        return titleBarHeight;
    }

    /**
     * 获取屏幕宽度px
     *
     * @param activity
     * @return
     */
    public static int getScreenWidth(Activity activity) {
        int screenWidth = activity.getResources().getDisplayMetrics().widthPixels;
        return screenWidth;
    }

    /**
     * 获取屏幕高度px
     *
     * @param activity
     * @return
     */
    public static int getScreenHeight(Activity activity) {
        int screenHeight = activity.getResources().getDisplayMetrics().heightPixels;
        return screenHeight;
    }


    /**
     * 将z字符串存在文件里
     *
     * @param message
     * @param fileName
     */
    public static void writeFileSdcard(String message, String fileName) {

        try {
            String messages = message + "\n";
            File file = new File(fileName);
            if (!file.exists()) {
                file.createNewFile();
            }
            FileOutputStream fout = new FileOutputStream(fileName);
            byte[] bytes = messages.getBytes();
            fout.write(bytes);
            fout.close();
        } catch (Exception e) {
            e.printStackTrace();

        }
    }

    /**
     * 计算展示图片高度
     *
     * @param width
     * @param height
     * @param targetWidth
     * @return
     */
    public static int computeHight(String width, String height, int targetWidth, float rate) {
        int targetHeight = 0;
        try {
            float w = Float.parseFloat(width);
            float h = Float.parseFloat(height);
            if (w > h) {
                targetHeight = (int) (targetWidth * rate);
            } else if (width == height) {
                targetHeight = (int) (h * targetWidth / w);
            } else {
                targetHeight = (int) (targetWidth / rate);
            }

        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        } finally {
            return targetHeight;
        }

    }


    /**
     * 弹出toast
     *
     * @param context
     * @param value
     */
    public static void addToast(Context context, String value) {
        try {
//            if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) &&MIUIUtil.isMIUI
// (context)) {
//                MIUIToast.makeText(context.getApplicationContext(), value, Toast.LENGTH_SHORT)
//                        .show();
//            } else {
//                Toast.makeText(context, value, Toast.LENGTH_SHORT).show();
//            }
            Toast.makeText(BaseApplication.self(), value, Toast.LENGTH_SHORT).show();
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
    }

    /**
     * 获取系统版本
     *
     * @return
     */
    public static int getSystemVersion() {
        int sysVersion = VERSION.SDK_INT;
        return sysVersion;
    }


    /**
     * 获取设备Id和手机品牌以“_”分隔
     *
     * @param context
     * @return
     */
    public static String getDeviceId(Context context) {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context
                .TELEPHONY_SERVICE);
        String result = "" + tm.getDeviceId() + "_" + Build.BRAND;
        return result;
    }


    /**
     * 获取版本号
     *
     * @return 当前应用的版本号
     */
    public static int getVersionCode(Context context) {
        int code = 1;
        try {
            PackageManager manager = context.getPackageManager();
            PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
            code = info.versionCode;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return code;
    }

    /**
     * 获取版本名称
     *
     * @return 当前应用的版本名称
     */
    public static String getVersionName(Context context) {
        String name = "";
        try {
            PackageManager manager = context.getPackageManager();
            PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
            name = info.versionName;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return name;
    }

    /**
     * 浏览器打开网页
     *
     * @param context
     * @param url
     */
    public static void openBrowser(Context context, String url) {
        Intent intent = new Intent();
        intent.setAction("android.intent.action.VIEW");
        Uri content_url = Uri.parse(url);
        intent.setData(content_url);
        context.startActivity(intent);
    }


    /**
     * 结束刷新
     *
     * @param swipeRefreshLayout
     */
    public static void setSwipeRefreshFinish(SwipeRefreshLayout swipeRefreshLayout) {
        swipeRefreshLayout.setRefreshing(false);
    }

    /**
     * 安装
     *
     * @param context 接收外部传进来的context
     */
    public static void install(Context context, String storePath) {
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
//            intent.setDataAndType(Uri.fromFile(new File(storePath)),
//                    "application/vnd.android.package-archive");


            if (Build.VERSION.SDK_INT >= 24) {
                intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                Uri contentUri = FileProvider.getUriForFile(context,
                         "test.com.cn.myapplication1", new File(storePath));
                intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
            } else {
                intent.setDataAndType(Uri.fromFile(new File(storePath)), "application/vnd.android.package-archive");
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            }
            context.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取本地apk文件的版本号
     *
     * @param context
     * @param storePath
     * @return
     */
    public static int getApkVersionCode(Context context, String storePath) {
        int versionCode = 1;
        PackageManager pm = context.getPackageManager();
        PackageInfo info = pm.getPackageArchiveInfo(storePath, PackageManager.GET_ACTIVITIES);
        ApplicationInfo appInfo = null;
        if (info != null) {
            appInfo = info.applicationInfo;
            versionCode = info.versionCode;
        }
        return versionCode;
    }

    /**
     * 获取本机号码
     *
     * @param context
     * @return
     */
    public static String getPhoneNumber(Context context) {
        String result = "";
        try {
            TelephonyManager mTelephonyMgr;
            mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            result = mTelephonyMgr.getLine1Number();
            if (result.startsWith(context.getString(R.string.base_86))) {
                result = result.replace(context.getString(R.string.base_86), "");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 设置输入框光标位置最后
     *
     * @param editText
     */
    public static void setCursor2Last(EditText editText) {
        editText.setSelection(editText.getText().length());
    }

    public static void setWebsettingBase(WebView webView) {
        WebSettings webSettings = webView.getSettings();
        //如果webView中需要用户手动输入用户名、密码或其他，则webview必须设置支持获取手势焦点
        webView.requestFocusFromTouch();
        webView.requestFocus();
        //打开页面时， 自适应屏幕
        webSettings.setUseWideViewPort(true);//关键点 设置此属性，可任意比例缩放
        webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
        webSettings.setLoadsImagesAutomatically(true);  //支持自动加载图片
        //支持通过JS打开新窗口
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        webSettings.setJavaScriptEnabled(true); // 设置支持javascript脚本
        //其他
        webSettings.setNeedInitialFocus(true); //当webview调用requestFocus时为webview设置节点
        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);//支持内容重新布局
        webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);  //webview中缓存
        webSettings.setAllowFileAccess(true); // 允许访问文件
        webSettings.supportMultipleWindows();  //多窗口
        // 开启 DOM storage API 功能?
        webSettings.setDomStorageEnabled(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);//http https混合运用
        }
        webSettings.setDefaultTextEncodingName("UTF-8");// 设置默认编码
        //开启 database storage API 功能?
        webSettings.setDatabaseEnabled(true);
//		String cacheDirPath = BaseConstant.IMAGETAMPPATH;
//		//设置? Application Caches 缓存目录?
//		webSettings.setAppCachePath(cacheDirPath);
//		//开启 Application Caches 功能?
//		webSettings.setAppCacheEnabled(true);
    }

    /**
     * 设置webview 不支持缩放
     *
     * @param webView
     */
    public static void setWebsetting(WebView webView) {
        setWebsettingBase(webView);
        WebSettings webSettings = webView.getSettings();
        //页面支持缩放
        webSettings.setBuiltInZoomControls(false); // 设置显示缩放按钮
        webSettings.setSupportZoom(false); // 支持缩放

    }

    /**
     * 设置webview 支持缩放
     *
     * @param webView
     */
    public static void setWebsetting2(WebView webView) {
        setWebsettingBase(webView);
        WebSettings webSettings = webView.getSettings();
        //页面支持缩放
        webSettings.setBuiltInZoomControls(true); // 设置显示缩放按钮
        webSettings.setSupportZoom(true); // 支持缩放
    }

    public static boolean isGpsOpen(final Activity activity, View view) {
        LocationManager locationManager = (LocationManager) activity.getSystemService(Context
                .LOCATION_SERVICE);
        if (locationManager.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) {
            return true;
        } else {
            DialogUtil dialogUtil = new DialogUtil(activity);
            dialogUtil.setDismissKeyback(true);
            dialogUtil.setDismissOutside(true);
            dialogUtil.setTitle(activity.getString(R.string.tip21));
            dialogUtil.showTipDialog(view, "");
            dialogUtil.setiOnDialogListener(new IOnDialogListener() {
                @Override
                public void onConfirm() {
                    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                    activity.startActivity(intent);
                }

                @Override
                public void onCancel() {

                }

                @Override
                public void onOther() {

                }
            });
        }
        return false;
    }

    /**
     * 打开应用设置
     *
     * @param context
     */
    public static void setting(final Context context) {
        try {
            new AlertDialog.Builder(context)
                    .setCancelable(false)
                    .setTitle("需要允许定位权限")
                    .setMessage("需要允许定位权限\n" +
                            "请点击『确定』，在弹出的『设置』界面中，设置司机宝允许定位权限。")
                    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface d, int w) {
                            Intent intent = new Intent(Settings.ACTION_SETTINGS);
//                            intent.setData(Uri.parse("package:" + context.getPackageName()));
                            context.startActivity(intent);
                        }
                    })
                    .show();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static String getUuid() {
        String timeStamp = "" + System.currentTimeMillis();
        return timeStamp;
    }

    //	public static String getUuid(){
//		UUID uuid = UUID.randomUUID();
//		return uuid.toString();
//	}
    public static String getWeatherFlag(Context context) {
        String result = "";
        try {
            String date = TimeUtil.getCurrentTime("yyyy-MM-dd");
            String city = SharedUtil.getChooseCity(context);
            result = date + "#" + city;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }


    /**
     * 获取运单状态
     * 1-待调度 2-待发车  20提货签到  21提货拍照-已装车 3-已发车  30到达签到 4-已到达  40到达拍照-完成  5-应到达 6-未识别7-已延期
     * 0-手动标记异常，-1撤销（系统标记异常） ,提货签到，提货拍照-已装车，到达签到，到达拍照-完成
     *
     * @param context     上下文
     * @param orderEntity 实体类
     * @return 状态
     */

    public static StatusEntity getOrderStatus(Context context, OrderEntity orderEntity) {
        StatusEntity statusEntity = new StatusEntity();
        String statusStr = "";
        int status = orderEntity.status;
        statusEntity.status = status;
//        if (status == ORDER_STATUS_2 && orderEntity.orderReceive != null && !StringUtil.isEmpty(orderEntity.orderReceive.operateTime)){
//            statusStr = context.getString(R.string.order_status_56);
//            statusEntity.status = ORDER_STATUS_10;
//        }
        if (status == ORDER_STATUS_2 && orderEntity.signStart != null && !StringUtil.isEmpty(orderEntity.signStart.operateTime)){
            statusStr = context.getString(R.string.order_status_8);
            statusEntity.status = ORDER_STATUS_20;
        }
        if (status == ORDER_STATUS_2 && orderEntity.startImage != null && !StringUtil.isEmpty(orderEntity.startImage.operateTime)) {
            statusStr = context.getString(R.string.order_status_11);
            statusEntity.status = ORDER_STATUS_21;
        }
        if (status == ORDER_STATUS_3 && orderEntity.signEnd != null && !StringUtil.isEmpty(orderEntity.signEnd.operateTime)) {
            statusStr = context.getString(R.string.order_status_9);
            statusEntity.status = ORDER_STATUS_30;
        }
        if (status == ORDER_STATUS_4 && orderEntity.signEnd != null && StringUtil.isEmpty(orderEntity.signEnd.operateTime)) {
            statusStr = context.getString(R.string.order_status_41);
            statusEntity.status = ORDER_STATUS_4;
        }
        if (status == ORDER_STATUS_4 && orderEntity.signEnd != null && !StringUtil.isEmpty(orderEntity.signEnd.operateTime) && orderEntity.arriveImage != null && StringUtil.isEmpty(orderEntity.arriveImage.operateTime)) {
            statusStr = context.getString(R.string.order_status_9);
            statusEntity.status = ORDER_STATUS_41;
        }
        if (status == ORDER_STATUS_3 && orderEntity.arriveImage != null && !StringUtil.isEmpty(orderEntity.arriveImage.operateTime)) {
            statusStr = context.getString(R.string.order_status_10);
            statusEntity.status = ORDER_STATUS_40;
        }
        if (status == ORDER_STATUS_4 && orderEntity.arriveImage != null && !StringUtil.isEmpty(orderEntity.arriveImage.operateTime)) {
            statusStr = context.getString(R.string.order_status_10);
            statusEntity.status = ORDER_STATUS_40;
        }


//        if (null != orderEntity.signStart && !StringUtil.isEmpty(orderEntity.signStart.operateTime) && status
//                == ORDER_STATUS_2) {
//            statusStr = context.getString(R.string.order_status_8);
//            statusEntity.status = ORDER_STATUS_20;
//        }
//        if (null != orderEntity.startImage && !StringUtil.isEmpty(orderEntity.startImage.operateTime) &&
//                status == ORDER_STATUS_2) {
//            statusStr = context.getString(R.string.order_status_11);
//            statusEntity.status = ORDER_STATUS_21;
//        }
//        if (null != orderEntity.signEnd && !StringUtil.isEmpty(orderEntity.signEnd.operateTime) && status ==
//                ORDER_STATUS_3) {
//            statusStr = context.getString(R.string.order_status_9);
//            statusEntity.status = ORDER_STATUS_30;
//        }
//        if (null != orderEntity.signEnd && StringUtil.isEmpty(orderEntity.signEnd.operateTime) && status ==
//                ORDER_STATUS_4) {
//            statusStr = context.getString(R.string.order_status_41);
//            statusEntity.status = ORDER_STATUS_4;
//        }
//        if (null != orderEntity.signEnd && !StringUtil.isEmpty(orderEntity.signEnd.operateTime) && null != orderEntity.arriveImage && StringUtil.isEmpty(orderEntity.arriveImage.operateTime) && status ==
//                ORDER_STATUS_4) {
//            statusStr = context.getString(R.string.order_status_9);
//            statusEntity.status = ORDER_STATUS_41;
//        }
//        if (null != orderEntity.arriveImage && !StringUtil.isEmpty(orderEntity.arriveImage.operateTime) &&
//                status == ORDER_STATUS_3) {
//            statusStr = context.getString(R.string.order_status_10);
//            statusEntity.status = ORDER_STATUS_40;
//        }
//        if (null != orderEntity.arriveImage && !StringUtil.isEmpty(orderEntity.arriveImage.operateTime) &&
//                status == ORDER_STATUS_4) {
//            statusStr = context.getString(R.string.order_status_10);
//            statusEntity.status = ORDER_STATUS_40;
//        }
        if (StringUtil.isEmpty(statusStr)) {
            switch (status) {

                case ORDER_STATUS_1:
                    statusStr = context.getString(R.string.order_status_1);
                    break;
                case ORDER_STATUS_10:
                    statusStr = context.getString(R.string.order_status_55);
                    break;
                case ORDER_STATUS_2:
                    //已接单
                    statusStr = context.getString(R.string.order_status_2);
                    break;
                case ORDER_STATUS_3:
                    statusStr = context.getString(R.string.order_status_3);
                    break;
                case ORDER_STATUS_4:
                    statusStr = context.getString(R.string.order_status_4);
                    break;
                case ORDER_STATUS_5:
                    statusStr = context.getString(R.string.order_status_5);
                    break;
                case ORDER_STATUS_6:
                    statusStr = context.getString(R.string.order_status_6);
                    break;
                case ORDER_STATUS_7:
                    statusStr = context.getString(R.string.order_status_7);
                    break;
                case ORDER_STATUS:
                    statusStr = context.getString(R.string.order_status_01);
                    break;
                case ORDER_STATUS_0:
                    statusStr = context.getString(R.string.order_status_0);
                    break;
            }
        }
        statusEntity.name = statusStr;
        return statusEntity;
    }

    public static ArrayList<String> formatImagesString(String imgs, String image_prefix) {
        ArrayList<String> list = new ArrayList<>();
        if (!StringUtil.isEmpty(imgs)) {
            String[] strs = imgs.split(",");
            for (String img : strs) {
                if (!img.startsWith("http")) {
                    list.add("" + BaseConstant.SERVICE_HOST_IP_LAN_IMG + img);
                } else {
                    list.add(img);
                }
            }
        }
        return list;
    }

    /**
     * 拼接字符串转换为list
     *
     * @param imgStr
     * @return
     */
    public static List<File> getImageList(String imgStr) {
        List<File> fileList = new ArrayList<>();
        String[] images = null;
        if (!StringUtil.isEmpty(imgStr)) {
            images = imgStr.split(",");
        }
        if (images != null) {
            for (String img : images) {
                File file = new File(img);
                fileList.add(file);
            }
        }
        return fileList;
    }

    /**
     * 获取进程名字
     *
     * @param cxt
     * @param pid
     * @return
     */
    public static String getProcessName(Context cxt, int pid) {
        ActivityManager am = (ActivityManager) cxt.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningAppProcessInfo> runningApps = am.getRunningAppProcesses();
        if (runningApps == null) {
            return null;
        }
        for (ActivityManager.RunningAppProcessInfo procInfo : runningApps) {
            if (procInfo.pid == pid) {
                return procInfo.processName;
            }
        }
        return null;
    }

}